home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_apache.idb / usr / freeware / apache / include / httpd / httpd.h.z / httpd.h
Encoding:
C/C++ Source or Header  |  1999-07-16  |  40.2 KB  |  1,130 lines

  1. /* ====================================================================
  2.  * Copyright (c) 1995-1999 The Apache Group.  All rights reserved.
  3.  *
  4.  * Redistribution and use in source and binary forms, with or without
  5.  * modification, are permitted provided that the following conditions
  6.  * are met:
  7.  *
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer. 
  10.  *
  11.  * 2. Redistributions in binary form must reproduce the above copyright
  12.  *    notice, this list of conditions and the following disclaimer in
  13.  *    the documentation and/or other materials provided with the
  14.  *    distribution.
  15.  *
  16.  * 3. All advertising materials mentioning features or use of this
  17.  *    software must display the following acknowledgment:
  18.  *    "This product includes software developed by the Apache Group
  19.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  20.  *
  21.  * 4. The names "Apache Server" and "Apache Group" must not be used to
  22.  *    endorse or promote products derived from this software without
  23.  *    prior written permission. For written permission, please contact
  24.  *    apache@apache.org.
  25.  *
  26.  * 5. Products derived from this software may not be called "Apache"
  27.  *    nor may "Apache" appear in their names without prior written
  28.  *    permission of the Apache Group.
  29.  *
  30.  * 6. Redistributions of any form whatsoever must retain the following
  31.  *    acknowledgment:
  32.  *    "This product includes software developed by the Apache Group
  33.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
  36.  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  37.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  38.  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  41.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  42.  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  43.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  44.  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  45.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  46.  * OF THE POSSIBILITY OF SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Group and was originally based
  51.  * on public domain software written at the National Center for
  52.  * Supercomputing Applications, University of Illinois, Urbana-Champaign.
  53.  * For more information on the Apache Group and the Apache HTTP server
  54.  * project, please see <http://www.apache.org/>.
  55.  *
  56.  */
  57.  
  58. #ifndef APACHE_HTTPD_H
  59. #define APACHE_HTTPD_H
  60.  
  61. #ifdef __cplusplus
  62. extern "C" {
  63. #endif
  64.  
  65. /*
  66.  * httpd.h: header for simple (ha! not anymore) http daemon
  67.  */
  68.  
  69. /* Headers in which EVERYONE has an interest... */
  70.  
  71. #include "ap_config.h"
  72. #include "alloc.h"
  73. #include "buff.h"
  74. #include "ap.h"
  75.  
  76. /* ----------------------------- config dir ------------------------------ */
  77.  
  78. /* Define this to be the default server home dir. Most things later in this
  79.  * file with a relative pathname will have this added.
  80.  */
  81. #ifndef HTTPD_ROOT
  82. #ifdef OS2
  83. /* Set default for OS/2 file system */
  84. #define HTTPD_ROOT "/os2httpd"
  85. #elif defined(WIN32)
  86. /* Set default for Windows file system */
  87. #define HTTPD_ROOT "/apache"
  88. #else
  89. #define HTTPD_ROOT "/usr/local/apache"
  90. #endif
  91. #endif /* HTTPD_ROOT */
  92.  
  93. /* Default location of documents.  Can be overridden by the DocumentRoot
  94.  * directive.
  95.  */
  96. #ifndef DOCUMENT_LOCATION
  97. #ifdef OS2
  98. /* Set default for OS/2 file system */
  99. #define DOCUMENT_LOCATION  HTTPD_ROOT "/docs"
  100. #else
  101. #define DOCUMENT_LOCATION  HTTPD_ROOT "/htdocs"
  102. #endif
  103. #endif /* DOCUMENT_LOCATION */
  104.  
  105. /* Max. number of dynamically loaded modules */
  106. #ifndef DYNAMIC_MODULE_LIMIT
  107. #define DYNAMIC_MODULE_LIMIT 64
  108. #endif
  109.  
  110. /* Default administrator's address */
  111. #define DEFAULT_ADMIN "[no address given]"
  112.  
  113. /* The target name of the installed Apache */
  114. #ifndef TARGET
  115. #define TARGET "httpd"
  116. #endif
  117.  
  118. /* 
  119.  * --------- You shouldn't have to edit anything below this line ----------
  120.  *
  121.  * Any modifications to any defaults not defined above should be done in the 
  122.  * respective config. file. 
  123.  *
  124.  */
  125.  
  126.  
  127. /* -- Internal representation for a HTTP protocol number, e.g., HTTP/1.1 -- */
  128.  
  129. #define HTTP_VERSION(major,minor) (1000*(major)+(minor))
  130. #define HTTP_VERSION_MAJOR(number) ((number)/1000)
  131. #define HTTP_VERSION_MINOR(number) ((number)%1000)
  132.  
  133.  
  134. /* -------------- Port number for server running standalone --------------- */
  135.  
  136. #define DEFAULT_HTTP_PORT    80
  137. #define DEFAULT_HTTPS_PORT    443
  138. #define ap_is_default_port(port,r)    ((port) == ap_default_port(r))
  139. #define ap_http_method(r)    "http"
  140. #define ap_default_port(r)    DEFAULT_HTTP_PORT
  141.  
  142. /* --------- Default user name and group name running standalone ---------- */
  143. /* --- These may be specified as numbers by placing a # before a number --- */
  144.  
  145. #ifndef DEFAULT_USER
  146. #define DEFAULT_USER "#-1"
  147. #endif
  148. #ifndef DEFAULT_GROUP
  149. #define DEFAULT_GROUP "#-1"
  150. #endif
  151.  
  152. /* The name of the log files */
  153. #ifndef DEFAULT_XFERLOG
  154. #ifdef OS2
  155. /* Set default for OS/2 file system */
  156. #define DEFAULT_XFERLOG "logs/access.log"
  157. #else
  158. #define DEFAULT_XFERLOG "logs/access_log"
  159. #endif
  160. #endif /* DEFAULT_XFERLOG */
  161.  
  162. #ifndef DEFAULT_ERRORLOG
  163. #ifdef OS2
  164. /* Set default for OS/2 file system */
  165. #define DEFAULT_ERRORLOG "logs/error.log"
  166. #else
  167. #define DEFAULT_ERRORLOG "logs/error_log"
  168. #endif
  169. #endif /* DEFAULT_ERRORLOG */
  170.  
  171. #ifndef DEFAULT_PIDLOG
  172. #define DEFAULT_PIDLOG "logs/httpd.pid"
  173. #endif
  174. #ifndef DEFAULT_SCOREBOARD
  175. #define DEFAULT_SCOREBOARD "logs/apache_runtime_status"
  176. #endif
  177. #ifndef DEFAULT_LOCKFILE
  178. #define DEFAULT_LOCKFILE "logs/accept.lock"
  179. #endif
  180.  
  181. /* Define this to be what your HTML directory content files are called */
  182. #ifndef DEFAULT_INDEX
  183. #define DEFAULT_INDEX "index.html"
  184. #endif
  185.  
  186. /* Define this to 1 if you want fancy indexing, 0 otherwise */
  187. #ifndef DEFAULT_INDEXING
  188. #define DEFAULT_INDEXING 0
  189. #endif
  190.  
  191. /* Define this to be what type you'd like returned for files with unknown */
  192. /* suffixes.  MUST be all lower case. */
  193. #ifndef DEFAULT_CONTENT_TYPE
  194. #define DEFAULT_CONTENT_TYPE "text/plain"
  195. #endif
  196.  
  197. /* Define this to be what your per-directory security files are called */
  198. #ifndef DEFAULT_ACCESS_FNAME
  199. #ifdef OS2
  200. /* Set default for OS/2 file system */
  201. #define DEFAULT_ACCESS_FNAME "htaccess"
  202. #else
  203. #define DEFAULT_ACCESS_FNAME ".htaccess"
  204. #endif
  205. #endif /* DEFAULT_ACCESS_FNAME */
  206.  
  207. /* The name of the server config file */
  208. #ifndef SERVER_CONFIG_FILE
  209. #define SERVER_CONFIG_FILE "conf/httpd.conf"
  210. #endif
  211.  
  212. /* The name of the document config file */
  213. #ifndef RESOURCE_CONFIG_FILE
  214. #define RESOURCE_CONFIG_FILE "conf/srm.conf"
  215. #endif
  216.  
  217. /* The name of the MIME types file */
  218. #ifndef TYPES_CONFIG_FILE
  219. #define TYPES_CONFIG_FILE "conf/mime.types"
  220. #endif
  221.  
  222. /* The name of the access file */
  223. #ifndef ACCESS_CONFIG_FILE
  224. #define ACCESS_CONFIG_FILE "conf/access.conf"
  225. #endif
  226.  
  227. /* Whether we should enable rfc1413 identity checking */
  228. #ifndef DEFAULT_RFC1413
  229. #define DEFAULT_RFC1413 0
  230. #endif
  231. /* The default directory in user's home dir */
  232. #ifndef DEFAULT_USER_DIR
  233. #define DEFAULT_USER_DIR "public_html"
  234. #endif
  235.  
  236. /* The default path for CGI scripts if none is currently set */
  237. #ifndef DEFAULT_PATH
  238. #define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin"
  239. #endif
  240.  
  241. /* The path to the shell interpreter, for parsed docs */
  242. #ifndef SHELL_PATH
  243. #if defined(OS2) || defined(WIN32)
  244. /* Set default for OS/2 and Windows file system */
  245. #define SHELL_PATH "CMD.EXE"
  246. #else
  247. #define SHELL_PATH "/bin/sh"
  248. #endif
  249. #endif /* SHELL_PATH */
  250.  
  251. /* The path to the suExec wrapper, can be overridden in Configuration */
  252. #ifndef SUEXEC_BIN
  253. #define SUEXEC_BIN  HTTPD_ROOT "/sbin/suexec"
  254. #endif
  255.  
  256. /* The default string lengths */
  257. #define MAX_STRING_LEN HUGE_STRING_LEN
  258. #define HUGE_STRING_LEN 8192
  259.  
  260. /* The timeout for waiting for messages */
  261. #ifndef DEFAULT_TIMEOUT
  262. #define DEFAULT_TIMEOUT 300
  263. #endif
  264.  
  265. /* The timeout for waiting for keepalive timeout until next request */
  266. #ifndef DEFAULT_KEEPALIVE_TIMEOUT
  267. #define DEFAULT_KEEPALIVE_TIMEOUT 15
  268. #endif
  269.  
  270. /* The number of requests to entertain per connection */
  271. #ifndef DEFAULT_KEEPALIVE
  272. #define DEFAULT_KEEPALIVE 100
  273. #endif
  274.  
  275. /* The size of the server's internal read-write buffers */
  276. #define IOBUFSIZE 8192
  277.  
  278. /* Number of servers to spawn off by default --- also, if fewer than
  279.  * this free when the caretaker checks, it will spawn more.
  280.  */
  281. #ifndef DEFAULT_START_DAEMON
  282. #define DEFAULT_START_DAEMON 5
  283. #endif
  284.  
  285. /* Maximum number of *free* server processes --- more than this, and
  286.  * they will die off.
  287.  */
  288.  
  289. #ifndef DEFAULT_MAX_FREE_DAEMON
  290. #define DEFAULT_MAX_FREE_DAEMON 10
  291. #endif
  292.  
  293. /* Minimum --- fewer than this, and more will be created */
  294.  
  295. #ifndef DEFAULT_MIN_FREE_DAEMON
  296. #define DEFAULT_MIN_FREE_DAEMON 5
  297. #endif
  298.  
  299. /* Limit on the total --- clients will be locked out if more servers than
  300.  * this are needed.  It is intended solely to keep the server from crashing
  301.  * when things get out of hand.
  302.  *
  303.  * We keep a hard maximum number of servers, for two reasons --- first off,
  304.  * in case something goes seriously wrong, we want to stop the fork bomb
  305.  * short of actually crashing the machine we're running on by filling some
  306.  * kernel table.  Secondly, it keeps the size of the scoreboard file small
  307.  * enough that we can read the whole thing without worrying too much about
  308.  * the overhead.
  309.  */
  310. #ifndef HARD_SERVER_LIMIT
  311. #define HARD_SERVER_LIMIT 256
  312. #endif
  313.  
  314. /*
  315.  * Special Apache error codes. These are basically used
  316.  *  in http_main.c so we can keep track of various errors.
  317.  *
  318.  *   APEXIT_OK:
  319.  *     A normal exit
  320.  *   APEXIT_INIT:
  321.  *     A fatal error arising during the server's init sequence
  322.  *   APEXIT_CHILDINIT:
  323.  *     The child died during it's init sequence
  324.  *   APEXIT_CHILDFATAL:
  325.  *     A fatal error, resulting in the whole server aborting.
  326.  *     If a child exits with this error, the parent process
  327.  *     considers this a server-wide fatal error and aborts.
  328.  *                 
  329.  */
  330. #define APEXIT_OK        0x0
  331. #define APEXIT_INIT        0x2
  332. #define APEXIT_CHILDINIT    0x3
  333. #define APEXIT_CHILDFATAL    0xf
  334.  
  335. /*
  336.  * (Unix, OS/2 only)
  337.  * Interval, in microseconds, between scoreboard maintenance.  During
  338.  * each scoreboard maintenance cycle the parent decides if it needs to
  339.  * spawn a new child (to meet MinSpareServers requirements), or kill off
  340.  * a child (to meet MaxSpareServers requirements).  It will only spawn or
  341.  * kill one child per cycle.  Setting this too low will chew cpu.  The
  342.  * default is probably sufficient for everyone.  But some people may want
  343.  * to raise this on servers which aren't dedicated to httpd and where they
  344.  * don't like the httpd waking up each second to see what's going on.
  345.  */
  346. #ifndef SCOREBOARD_MAINTENANCE_INTERVAL
  347. #define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
  348. #endif
  349.  
  350. /* Number of requests to try to handle in a single process.  If <= 0,
  351.  * the children don't die off.  That's the default here, since I'm still
  352.  * interested in finding and stanching leaks.
  353.  */
  354.  
  355. #ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
  356. #define DEFAULT_MAX_REQUESTS_PER_CHILD 0
  357. #endif
  358.  
  359. #ifndef DEFAULT_THREADS_PER_CHILD
  360. #define DEFAULT_THREADS_PER_CHILD 50
  361. #endif
  362. #ifndef DEFAULT_EXCESS_REQUESTS_PER_CHILD
  363. #define DEFAULT_EXCESS_REQUESTS_PER_CHILD 0
  364. #endif
  365.  
  366. /* The maximum length of the queue of pending connections, as defined
  367.  * by listen(2).  Under some systems, it should be increased if you
  368.  * are experiencing a heavy TCP SYN flood attack.
  369.  *
  370.  * It defaults to 511 instead of 512 because some systems store it 
  371.  * as an 8-bit datatype; 512 truncated to 8-bits is 0, while 511 is 
  372.  * 255 when truncated.
  373.  */
  374.  
  375. #ifndef DEFAULT_LISTENBACKLOG
  376. #define DEFAULT_LISTENBACKLOG 511
  377. #endif
  378.  
  379. /* Limits on the size of various request items.  These limits primarily
  380.  * exist to prevent simple denial-of-service attacks on a server based
  381.  * on misuse of the protocol.  The recommended values will depend on the
  382.  * nature of the server resources -- CGI scripts and database backends
  383.  * might require large values, but most servers could get by with much
  384.  * smaller limits than we use below.  The request message body size can
  385.  * be limited by the per-dir config directive LimitRequestBody.
  386.  *
  387.  * Internal buffer sizes are two bytes more than the DEFAULT_LIMIT_REQUEST_LINE
  388.  * and DEFAULT_LIMIT_REQUEST_FIELDSIZE below, which explains the 8190.
  389.  * These two limits can be lowered (but not raised) by the server config
  390.  * directives LimitRequestLine and LimitRequestFieldsize, respectively.
  391.  *
  392.  * DEFAULT_LIMIT_REQUEST_FIELDS can be modified or disabled (set = 0) by
  393.  * the server config directive LimitRequestFields.
  394.  */
  395. #ifndef DEFAULT_LIMIT_REQUEST_LINE
  396. #define DEFAULT_LIMIT_REQUEST_LINE 8190
  397. #endif /* default limit on bytes in Request-Line (Method+URI+HTTP-version) */
  398. #ifndef DEFAULT_LIMIT_REQUEST_FIELDSIZE
  399. #define DEFAULT_LIMIT_REQUEST_FIELDSIZE 8190
  400. #endif /* default limit on bytes in any one header field  */
  401. #ifndef DEFAULT_LIMIT_REQUEST_FIELDS
  402. #define DEFAULT_LIMIT_REQUEST_FIELDS 100
  403. #endif /* default limit on number of request header fields */
  404.  
  405. /*
  406.  * The below defines the base string of the Server: header. Additional
  407.  * tokens can be added via the ap_add_version_component() API call.
  408.  *
  409.  * The tokens are listed in order of their significance for identifying the
  410.  * application.
  411.  *
  412.  * "Product tokens should be short and to the point -- use of them for 
  413.  * advertizing or other non-essential information is explicitly forbidden."
  414.  *
  415.  * Example: "Apache/1.1.0 MrWidget/0.1-alpha" 
  416.  */
  417.  
  418. #define SERVER_BASEVERSION "Apache/1.3.4"       /* SEE COMMENTS ABOVE */
  419. #define SERVER_VERSION  SERVER_BASEVERSION
  420. enum server_token_type {
  421.     SrvTk_MIN,        /* eg: Apache/1.3.0 */
  422.     SrvTk_OS,        /* eg: Apache/1.3.0 (UNIX) */
  423.     SrvTk_FULL        /* eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b */
  424. };
  425.  
  426. API_EXPORT(const char *) ap_get_server_version(void);
  427. API_EXPORT(void) ap_add_version_component(const char *component);
  428. API_EXPORT(const char *) ap_get_server_built(void);
  429.  
  430. /* Numeric release version identifier: MMNNFFRBB: major minor fix final beta
  431.  * Always increases along the same track as the source branch.
  432.  * For example, Apache 1.4.2 would be '10402100', 2.5b7 would be '20500007'.
  433.  */
  434. #define APACHE_RELEASE 10304100
  435.  
  436. #define SERVER_PROTOCOL "HTTP/1.1"
  437. #ifndef SERVER_SUPPORT
  438. #define SERVER_SUPPORT "http://www.apache.org/"
  439. #endif
  440.  
  441. #define DECLINED -1        /* Module declines to handle */
  442. #define DONE -2            /* Module has served the response completely 
  443.                  *  - it's safe to die() with no more output
  444.                  */
  445. #define OK 0            /* Module has handled this stage. */
  446.  
  447.  
  448. /* ----------------------- HTTP Status Codes  ------------------------- */
  449.  
  450. /* The size of the static array in http_protocol.c for storing
  451.  * all of the potential response status-lines (a sparse table).
  452.  * A future version should dynamically generate the table at startup.
  453.  */
  454. #define RESPONSE_CODES 55
  455.  
  456. #define HTTP_CONTINUE                      100
  457. #define HTTP_SWITCHING_PROTOCOLS           101
  458. #define HTTP_PROCESSING                    102
  459. #define HTTP_OK                            200
  460. #define HTTP_CREATED                       201
  461. #define HTTP_ACCEPTED                      202
  462. #define HTTP_NON_AUTHORITATIVE             203
  463. #define HTTP_NO_CONTENT                    204
  464. #define HTTP_RESET_CONTENT                 205
  465. #define HTTP_PARTIAL_CONTENT               206
  466. #define HTTP_MULTI_STATUS                  207
  467. #define HTTP_MULTIPLE_CHOICES              300
  468. #define HTTP_MOVED_PERMANENTLY             301
  469. #define HTTP_MOVED_TEMPORARILY             302
  470. #define HTTP_SEE_OTHER                     303
  471. #define HTTP_NOT_MODIFIED                  304
  472. #define HTTP_USE_PROXY                     305
  473. #define HTTP_TEMPORARY_REDIRECT            307
  474. #define HTTP_BAD_REQUEST                   400
  475. #define HTTP_UNAUTHORIZED                  401
  476. #define HTTP_PAYMENT_REQUIRED              402
  477. #define HTTP_FORBIDDEN                     403
  478. #define HTTP_NOT_FOUND                     404
  479. #define HTTP_METHOD_NOT_ALLOWED            405
  480. #define HTTP_NOT_ACCEPTABLE                406
  481. #define HTTP_PROXY_AUTHENTICATION_REQUIRED 407
  482. #define HTTP_REQUEST_TIME_OUT              408
  483. #define HTTP_CONFLICT                      409
  484. #define HTTP_GONE                          410
  485. #define HTTP_LENGTH_REQUIRED               411
  486. #define HTTP_PRECONDITION_FAILED           412
  487. #define HTTP_REQUEST_ENTITY_TOO_LARGE      413
  488. #define HTTP_REQUEST_URI_TOO_LARGE         414
  489. #define HTTP_UNSUPPORTED_MEDIA_TYPE        415
  490. #define HTTP_RANGE_NOT_SATISFIABLE         416
  491. #define HTTP_EXPECTATION_FAILED            417
  492. #define HTTP_UNPROCESSABLE_ENTITY          422
  493. #define HTTP_LOCKED                        423
  494. #define HTTP_FAILED_DEPENDENCY             424
  495. #define HTTP_INTERNAL_SERVER_ERROR         500
  496. #define HTTP_NOT_IMPLEMENTED               501
  497. #define HTTP_BAD_GATEWAY                   502
  498. #define HTTP_SERVICE_UNAVAILABLE           503
  499. #define HTTP_GATEWAY_TIME_OUT              504
  500. #define HTTP_VERSION_NOT_SUPPORTED         505
  501. #define HTTP_VARIANT_ALSO_VARIES           506
  502. #define HTTP_INSUFFICIENT_STORAGE          507
  503. #define HTTP_NOT_EXTENDED                  510
  504.  
  505. #define DOCUMENT_FOLLOWS    HTTP_OK
  506. #define PARTIAL_CONTENT     HTTP_PARTIAL_CONTENT
  507. #define MULTIPLE_CHOICES    HTTP_MULTIPLE_CHOICES
  508. #define MOVED               HTTP_MOVED_PERMANENTLY
  509. #define REDIRECT            HTTP_MOVED_TEMPORARILY
  510. #define USE_LOCAL_COPY      HTTP_NOT_MODIFIED
  511. #define BAD_REQUEST         HTTP_BAD_REQUEST
  512. #define AUTH_REQUIRED       HTTP_UNAUTHORIZED
  513. #define FORBIDDEN           HTTP_FORBIDDEN
  514. #define NOT_FOUND           HTTP_NOT_FOUND
  515. #define METHOD_NOT_ALLOWED  HTTP_METHOD_NOT_ALLOWED
  516. #define NOT_ACCEPTABLE      HTTP_NOT_ACCEPTABLE
  517. #define LENGTH_REQUIRED     HTTP_LENGTH_REQUIRED
  518. #define PRECONDITION_FAILED HTTP_PRECONDITION_FAILED
  519. #define SERVER_ERROR        HTTP_INTERNAL_SERVER_ERROR
  520. #define NOT_IMPLEMENTED     HTTP_NOT_IMPLEMENTED
  521. #define BAD_GATEWAY         HTTP_BAD_GATEWAY
  522. #define VARIANT_ALSO_VARIES HTTP_VARIANT_ALSO_VARIES
  523.  
  524. #define ap_is_HTTP_INFO(x)         (((x) >= 100)&&((x) < 200))
  525. #define ap_is_HTTP_SUCCESS(x)      (((x) >= 200)&&((x) < 300))
  526. #define ap_is_HTTP_REDIRECT(x)     (((x) >= 300)&&((x) < 400))
  527. #define ap_is_HTTP_ERROR(x)        (((x) >= 400)&&((x) < 600))
  528. #define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500))
  529. #define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600))
  530.  
  531. #define ap_status_drops_connection(x) \
  532.                                    (((x) == HTTP_BAD_REQUEST)           || \
  533.                                     ((x) == HTTP_REQUEST_TIME_OUT)      || \
  534.                                     ((x) == HTTP_LENGTH_REQUIRED)       || \
  535.                                     ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \
  536.                                     ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \
  537.                                     ((x) == HTTP_INTERNAL_SERVER_ERROR) || \
  538.                                     ((x) == HTTP_SERVICE_UNAVAILABLE) || \
  539.                     ((x) == HTTP_NOT_IMPLEMENTED))
  540.  
  541. /* Methods recognized (but not necessarily handled) by the server.
  542.  * These constants are used in bit shifting masks of size int, so it is
  543.  * unsafe to have more methods than bits in an int.  HEAD == M_GET.
  544.  */
  545. #define M_GET        0
  546. #define M_PUT        1
  547. #define M_POST       2
  548. #define M_DELETE     3
  549. #define M_CONNECT    4
  550. #define M_OPTIONS    5
  551. #define M_TRACE      6
  552. #define M_PATCH      7
  553. #define M_PROPFIND   8
  554. #define M_PROPPATCH  9
  555. #define M_MKCOL     10
  556. #define M_COPY      11
  557. #define M_MOVE      12
  558. #define M_LOCK      13
  559. #define M_UNLOCK    14
  560.  
  561. #define METHODS     15
  562. #define M_INVALID   31
  563.  
  564. #define CGI_MAGIC_TYPE "application/x-httpd-cgi"
  565. #define INCLUDES_MAGIC_TYPE "text/x-server-parsed-html"
  566. #define INCLUDES_MAGIC_TYPE3 "text/x-server-parsed-html3"
  567. #ifdef CHARSET_EBCDIC
  568. #define ASCIITEXT_MAGIC_TYPE_PREFIX "text/x-ascii-" /* Text files whose content-type starts with this are passed thru unconverted */
  569. #endif /*CHARSET_EBCDIC*/
  570. #define MAP_FILE_MAGIC_TYPE "application/x-type-map"
  571. #define ASIS_MAGIC_TYPE "httpd/send-as-is"
  572. #define DIR_MAGIC_TYPE "httpd/unix-directory"
  573. #define STATUS_MAGIC_TYPE "application/x-httpd-status"
  574.  
  575. /* Just in case your linefeed isn't the one the other end is expecting. */
  576. #ifndef CHARSET_EBCDIC
  577. #define LF 10
  578. #define CR 13
  579. #else /* CHARSET_EBCDIC */
  580. #include "ebcdic.h"
  581. /* OSD_POSIX uses the EBCDIC charset. The transition ASCII->EBCDIC is done in
  582.  * the buff package (bread/bputs/bwrite), so everywhere else, we use
  583.  * "native EBCDIC" CR and NL characters. These are therefore defined as
  584.  * '\r' and '\n'.
  585.  * NB: this is not the whole truth - sometimes \015 and \012 are contained
  586.  * in literal (EBCDIC!) strings, so these are not converted but passed.
  587.  */
  588. #define CR '\r'
  589. #define LF '\n'
  590. #endif /* CHARSET_EBCDIC */
  591.  
  592. /* Possible values for request_rec.read_body (set by handling module):
  593.  *    REQUEST_NO_BODY          Send 413 error if message has any body
  594.  *    REQUEST_CHUNKED_ERROR    Send 411 error if body without Content-Length
  595.  *    REQUEST_CHUNKED_DECHUNK  If chunked, remove the chunks for me.
  596.  *    REQUEST_CHUNKED_PASS     Pass the chunks to me without removal.
  597.  */
  598. #define REQUEST_NO_BODY          0
  599. #define REQUEST_CHUNKED_ERROR    1
  600. #define REQUEST_CHUNKED_DECHUNK  2
  601. #define REQUEST_CHUNKED_PASS     3
  602.  
  603. /* Things which may vary per file-lookup WITHIN a request ---
  604.  * e.g., state of MIME config.  Basically, the name of an object, info
  605.  * about the object, and any other info we may ahve which may need to
  606.  * change as we go poking around looking for it (e.g., overridden by
  607.  * .htaccess files).
  608.  *
  609.  * Note how the default state of almost all these things is properly
  610.  * zero, so that allocating it with pcalloc does the right thing without
  611.  * a whole lot of hairy initialization... so long as we are willing to
  612.  * make the (fairly) portable assumption that the bit pattern of a NULL
  613.  * pointer is, in fact, zero.
  614.  */
  615.  
  616. /* This represents the result of calling htaccess; these are cached for
  617.  * each request.
  618.  */
  619. struct htaccess_result {
  620.     char *dir;            /* the directory to which this applies */
  621.     int override;        /* the overrides allowed for the .htaccess file */
  622.     void *htaccess;        /* the configuration directives */
  623. /* the next one, or NULL if no more; N.B. never change this */
  624.     const struct htaccess_result *next;
  625. };
  626.  
  627. typedef struct conn_rec conn_rec;
  628. typedef struct server_rec server_rec;
  629. typedef struct request_rec request_rec;
  630. typedef struct listen_rec listen_rec;
  631.  
  632. #include "util_uri.h"
  633.  
  634. struct request_rec {
  635.  
  636.     ap_pool *pool;
  637.     conn_rec *connection;
  638.     server_rec *server;
  639.  
  640.     request_rec *next;        /* If we wind up getting redirected,
  641.                  * pointer to the request we redirected to.
  642.                  */
  643.     request_rec *prev;        /* If this is an internal redirect,
  644.                  * pointer to where we redirected *from*.
  645.                  */
  646.  
  647.     request_rec *main;        /* If this is a sub_request (see request.h) 
  648.                  * pointer back to the main request.
  649.                  */
  650.  
  651.     /* Info about the request itself... we begin with stuff that only
  652.      * protocol.c should ever touch...
  653.      */
  654.  
  655.     char *the_request;        /* First line of request, so we can log it */
  656.     int assbackwards;        /* HTTP/0.9, "simple" request */
  657.     int proxyreq;        /* A proxy request (calculated during
  658.                  * post_read_request or translate_name) */
  659.     int header_only;        /* HEAD request, as opposed to GET */
  660.     char *protocol;        /* Protocol, as given to us, or HTTP/0.9 */
  661.     int proto_num;        /* Number version of protocol; 1.1 = 1001 */
  662.     const char *hostname;    /* Host, as set by full URI or Host: */
  663.  
  664.     time_t request_time;    /* When the request started */
  665.  
  666.     char *status_line;        /* Status line, if set by script */
  667.     int status;            /* In any case */
  668.  
  669.     /* Request method, two ways; also, protocol, etc..  Outside of protocol.c,
  670.      * look, but don't touch.
  671.      */
  672.  
  673.     char *method;        /* GET, HEAD, POST, etc. */
  674.     int method_number;        /* M_GET, M_POST, etc. */
  675.  
  676.     /*
  677.     allowed is a bitvector of the allowed methods.
  678.  
  679.     A handler must ensure that the request method is one that
  680.     it is capable of handling.  Generally modules should DECLINE
  681.     any request methods they do not handle.  Prior to aborting the
  682.     handler like this the handler should set r->allowed to the list
  683.     of methods that it is willing to handle.  This bitvector is used
  684.     to construct the "Allow:" header required for OPTIONS requests,
  685.     and METHOD_NOT_ALLOWED and NOT_IMPLEMENTED status codes.
  686.  
  687.     Since the default_handler deals with OPTIONS, all modules can
  688.     usually decline to deal with OPTIONS.  TRACE is always allowed,
  689.     modules don't need to set it explicitly.
  690.  
  691.     Since the default_handler will always handle a GET, a
  692.     module which does *not* implement GET should probably return
  693.     METHOD_NOT_ALLOWED.  Unfortunately this means that a Script GET
  694.     handler can't be installed by mod_actions.
  695.     */
  696.     int allowed;        /* Allowed methods - for 405, OPTIONS, etc */
  697.  
  698.     int sent_bodyct;        /* byte count in stream is for body */
  699.     long bytes_sent;        /* body byte count, for easy access */
  700.     time_t mtime;        /* Time the resource was last modified */
  701.  
  702.     /* HTTP/1.1 connection-level features */
  703.  
  704.     int chunked;        /* sending chunked transfer-coding */
  705.     int byterange;        /* number of byte ranges */
  706.     char *boundary;        /* multipart/byteranges boundary */
  707.     const char *range;        /* The Range: header */
  708.     long clength;        /* The "real" content length */
  709.  
  710.     long remaining;        /* bytes left to read */
  711.     long read_length;        /* bytes that have been read */
  712.     int read_body;        /* how the request body should be read */
  713.     int read_chunked;        /* reading chunked transfer-coding */
  714.     unsigned expecting_100;    /* is client waiting for a 100 response? */
  715.  
  716.     /* MIME header environments, in and out.  Also, an array containing
  717.      * environment variables to be passed to subprocesses, so people can
  718.      * write modules to add to that environment.
  719.      *
  720.      * The difference between headers_out and err_headers_out is that the
  721.      * latter are printed even on error, and persist across internal redirects
  722.      * (so the headers printed for ErrorDocument handlers will have them).
  723.      *
  724.      * The 'notes' table is for notes from one module to another, with no
  725.      * other set purpose in mind...
  726.      */
  727.  
  728.     table *headers_in;
  729.     table *headers_out;
  730.     table *err_headers_out;
  731.     table *subprocess_env;
  732.     table *notes;
  733.  
  734.     /* content_type, handler, content_encoding, content_language, and all
  735.      * content_languages MUST be lowercased strings.  They may be pointers
  736.      * to static strings; they should not be modified in place.
  737.      */
  738.     const char *content_type;    /* Break these out --- we dispatch on 'em */
  739.     const char *handler;    /* What we *really* dispatch on           */
  740.  
  741.     const char *content_encoding;
  742.     const char *content_language;    /* for back-compat. only -- do not use */
  743.     array_header *content_languages;    /* array of (char*) */
  744.  
  745.     char *vlist_validator;      /* variant list validator (if negotiated) */
  746.  
  747.     int no_cache;
  748.     int no_local_copy;
  749.  
  750.     /* What object is being requested (either directly, or via include
  751.      * or content-negotiation mapping).
  752.      */
  753.  
  754.     char *unparsed_uri;        /* the uri without any parsing performed */
  755.     char *uri;            /* the path portion of the URI */
  756.     char *filename;
  757.     char *path_info;
  758.     char *args;            /* QUERY_ARGS, if any */
  759.     struct stat finfo;        /* ST_MODE set to zero if no such file */
  760.     uri_components parsed_uri;    /* components of uri, dismantled */
  761.  
  762.     /* Various other config info which may change with .htaccess files
  763.      * These are config vectors, with one void* pointer for each module
  764.      * (the thing pointed to being the module's business).
  765.      */
  766.  
  767.     void *per_dir_config;    /* Options set in config files, etc. */
  768.     void *request_config;    /* Notes on *this* request */
  769.  
  770. /*
  771.  * a linked list of the configuration directives in the .htaccess files
  772.  * accessed by this request.
  773.  * N.B. always add to the head of the list, _never_ to the end.
  774.  * that way, a sub request's list can (temporarily) point to a parent's list
  775.  */
  776.     const struct htaccess_result *htaccess;
  777.  
  778. /* Things placed at the end of the record to avoid breaking binary
  779.  * compatibility.  It would be nice to remember to reorder the entire
  780.  * record to improve 64bit alignment the next time we need to break
  781.  * binary compatibility for some other reason.
  782.  */
  783. };
  784.  
  785.  
  786. /* Things which are per connection
  787.  */
  788.  
  789. struct conn_rec {
  790.  
  791.     ap_pool *pool;
  792.     server_rec *server;
  793.     server_rec *base_server;    /* Physical vhost this conn come in on */
  794.     void *vhost_lookup_data;    /* used by http_vhost.c */
  795.  
  796.     /* Information about the connection itself */
  797.  
  798.     int child_num;        /* The number of the child handling conn_rec */
  799.     BUFF *client;        /* Connection to the guy */
  800.  
  801.     /* Who is the client? */
  802.  
  803.     struct sockaddr_in local_addr;    /* local address */
  804.     struct sockaddr_in remote_addr;    /* remote address */
  805.     char *remote_ip;        /* Client's IP address */
  806.     char *remote_host;        /* Client's DNS name, if known.
  807.                  * NULL if DNS hasn't been checked,
  808.                  * "" if it has and no address was found.
  809.                  * N.B. Only access this though
  810.                  * get_remote_host() */
  811.     char *remote_logname;    /* Only ever set if doing rfc1413 lookups.
  812.                  * N.B. Only access this through
  813.                  * get_remote_logname() */
  814.     char *user;            /* If an authentication check was made,
  815.                  * this gets set to the user name.  We assume
  816.                  * that there's only one user per connection(!)
  817.                  */
  818.     char *ap_auth_type;        /* Ditto. */
  819.  
  820.     unsigned aborted:1;        /* Are we still talking? */
  821.     signed int keepalive:2;    /* Are we using HTTP Keep-Alive?
  822.                  * -1 fatal error, 0 undecided, 1 yes */
  823.     unsigned keptalive:1;    /* Did we use HTTP Keep-Alive? */
  824.     signed int double_reverse:2;/* have we done double-reverse DNS?
  825.                  * -1 yes/failure, 0 not yet, 1 yes/success */
  826.     int keepalives;        /* How many times have we used it? */
  827. };
  828.  
  829. /* Per-vhost config... */
  830.  
  831. /* The address 255.255.255.255, when used as a virtualhost address,
  832.  * will become the "default" server when the ip doesn't match other vhosts.
  833.  */
  834. #define DEFAULT_VHOST_ADDR 0xfffffffful
  835.  
  836. typedef struct server_addr_rec server_addr_rec;
  837. struct server_addr_rec {
  838.     server_addr_rec *next;
  839.     struct in_addr host_addr;    /* The bound address, for this server */
  840.     unsigned short host_port;    /* The bound port, for this server */
  841.     char *virthost;        /* The name given in <VirtualHost> */
  842. };
  843.  
  844. struct server_rec {
  845.  
  846.     server_rec *next;
  847.  
  848.     /* description of where the definition came from */
  849.     const char *defn_name;
  850.     unsigned defn_line_number;
  851.  
  852.     /* Full locations of server config info */
  853.  
  854.     char *srm_confname;
  855.     char *access_confname;
  856.  
  857.     /* Contact information */
  858.  
  859.     char *server_admin;
  860.     char *server_hostname;
  861.     unsigned short port;    /* for redirects, etc. */
  862.  
  863.     /* Log files --- note that transfer log is now in the modules... */
  864.  
  865.     char *error_fname;
  866.     FILE *error_log;
  867.     int loglevel;
  868.  
  869.     /* Module-specific configuration for server, and defaults... */
  870.  
  871.     int is_virtual;        /* true if this is the virtual server */
  872.     void *module_config;    /* Config vector containing pointers to
  873.                  * modules' per-server config structures.
  874.                  */
  875.     void *lookup_defaults;    /* MIME type info, etc., before we start
  876.                  * checking per-directory info.
  877.                  */
  878.     /* Transaction handling */
  879.  
  880.     server_addr_rec *addrs;
  881.     int timeout;        /* Timeout, in seconds, before we give up */
  882.     int keep_alive_timeout;    /* Seconds we'll wait for another request */
  883.     int keep_alive_max;        /* Maximum requests per connection */
  884.     int keep_alive;        /* Use persistent connections? */
  885.     int send_buffer_size;    /* size of TCP send buffer (in bytes) */
  886.  
  887.     char *path;            /* Pathname for ServerPath */
  888.     int pathlen;        /* Length of path */
  889.  
  890.     array_header *names;    /* Normal names for ServerAlias servers */
  891.     array_header *wild_names;    /* Wildcarded names for ServerAlias servers */
  892.  
  893.     uid_t server_uid;        /* effective user id when calling exec wrapper */
  894.     gid_t server_gid;        /* effective group id when calling exec wrapper */
  895.  
  896.     int limit_req_line;      /* limit on size of the HTTP request line    */
  897.     int limit_req_fieldsize; /* limit on size of any request header field */
  898.     int limit_req_fields;    /* limit on number of request header fields  */
  899. };
  900.  
  901. /* These are more like real hosts than virtual hosts */
  902. struct listen_rec {
  903.     listen_rec *next;
  904.     struct sockaddr_in local_addr;    /* local IP address and port */
  905.     int fd;
  906.     int used;            /* Only used during restart */
  907. /* more stuff here, like which protocol is bound to the port */
  908. };
  909.  
  910. /* Prototypes for utilities... util.c.
  911.  */
  912.  
  913. extern void ap_util_init(void);
  914.  
  915. /* Time */
  916. extern API_VAR_EXPORT const char ap_month_snames[12][4];
  917. extern API_VAR_EXPORT const char ap_day_snames[7][4];
  918.  
  919. API_EXPORT(struct tm *) ap_get_gmtoff(int *tz);
  920. API_EXPORT(char *) ap_get_time(void);
  921. API_EXPORT(char *) ap_ht_time(pool *p, time_t t, const char *fmt, int gmt);
  922. API_EXPORT(char *) ap_gm_timestr_822(pool *p, time_t t);
  923.  
  924. /* String handling. The *_nc variants allow you to use non-const char **s as
  925.    arguments (unfortunately C won't automatically convert a char ** to a const
  926.    char **) */
  927.  
  928. API_EXPORT(char *) ap_getword(pool *p, const char **line, char stop);
  929. API_EXPORT(char *) ap_getword_nc(pool *p, char **line, char stop);
  930. API_EXPORT(char *) ap_getword_white(pool *p, const char **line);
  931. API_EXPORT(char *) ap_getword_white_nc(pool *p, char **line);
  932. API_EXPORT(char *) ap_getword_nulls(pool *p, const char **line, char stop);
  933. API_EXPORT(char *) ap_getword_nulls_nc(pool *p, char **line, char stop);
  934. API_EXPORT(char *) ap_getword_conf(pool *p, const char **line);
  935. API_EXPORT(char *) ap_getword_conf_nc(pool *p, char **line);
  936.  
  937. API_EXPORT(char *) ap_get_token(pool *p, const char **accept_line, int accept_white);
  938. API_EXPORT(int) ap_find_token(pool *p, const char *line, const char *tok);
  939. API_EXPORT(int) ap_find_last_token(pool *p, const char *line, const char *tok);
  940.  
  941. API_EXPORT(int) ap_is_url(const char *u);
  942. API_EXPORT(int) ap_unescape_url(char *url);
  943. API_EXPORT(void) ap_no2slash(char *name);
  944. API_EXPORT(void) ap_getparents(char *name);
  945. API_EXPORT(char *) ap_escape_path_segment(pool *p, const char *s);
  946. API_EXPORT(char *) ap_os_escape_path(pool *p, const char *path, int partial);
  947. #define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1)
  948. API_EXPORT(char *) ap_escape_html(pool *p, const char *s);
  949. API_EXPORT(char *) ap_construct_server(pool *p, const char *hostname,
  950.                     unsigned port, const request_rec *r);
  951. API_EXPORT(char *) ap_escape_shell_cmd(pool *p, const char *s);
  952.  
  953. API_EXPORT(int) ap_count_dirs(const char *path);
  954. API_EXPORT(char *) ap_make_dirstr_prefix(char *d, const char *s, int n);
  955. API_EXPORT(char *) ap_make_dirstr_parent(pool *p, const char *s);
  956. /* deprecated.  The previous two routines are preferred. */
  957. API_EXPORT(char *) ap_make_dirstr(pool *a, const char *s, int n);
  958. API_EXPORT(char *) ap_make_full_path(pool *a, const char *dir, const char *f);
  959.  
  960. API_EXPORT(int) ap_is_matchexp(const char *str);
  961. API_EXPORT(int) ap_strcmp_match(const char *str, const char *exp);
  962. API_EXPORT(int) ap_strcasecmp_match(const char *str, const char *exp);
  963. API_EXPORT(char *) ap_uudecode(pool *, const char *);
  964. API_EXPORT(char *) ap_uuencode(pool *p, char *string); 
  965. #ifdef OS2
  966. void os2pathname(char *path);
  967. #endif
  968.  
  969. API_EXPORT(char *) ap_pregsub(pool *p, const char *input, const char *source,
  970.                size_t nmatch, regmatch_t pmatch[]);
  971.  
  972. API_EXPORT(void) ap_content_type_tolower(char *);
  973. API_EXPORT(void) ap_str_tolower(char *);
  974. API_EXPORT(int) ap_ind(const char *, char);    /* Sigh... */
  975. API_EXPORT(int) ap_rind(const char *, char);
  976.  
  977. API_EXPORT(char *) ap_escape_quotes (pool *p, const char *instring);
  978.  
  979. /* Common structure for reading of config files / passwd files etc. */
  980. typedef struct {
  981.     int (*getch) (void *param);    /* a getc()-like function */
  982.     void *(*getstr) (void *buf, size_t bufsiz, void *param); /* a fgets()-like function */
  983.     int (*close) (void *param);    /* a close hander function */
  984.     void *param;        /* the argument passed to getch/getstr/close */
  985.     const char *name;        /* the filename / description */
  986.     unsigned line_number;    /* current line number, starting at 1 */
  987. } configfile_t;
  988.  
  989. /* Open a configfile_t as FILE, return open configfile_t struct pointer */
  990. API_EXPORT(configfile_t *) ap_pcfg_openfile(pool *p, const char *name);
  991.  
  992. /* Allocate a configfile_t handle with user defined functions and params */
  993. API_EXPORT(configfile_t *) ap_pcfg_open_custom(pool *p, const char *descr,
  994.     void *param,
  995.     int(*getc_func)(void*),
  996.     void *(*gets_func) (void *buf, size_t bufsiz, void *param),
  997.     int(*close_func)(void *param));
  998.  
  999. /* Read one line from open configfile_t, strip LF, increase line number */
  1000. API_EXPORT(int) ap_cfg_getline(char *buf, size_t bufsize, configfile_t *cfp);
  1001.  
  1002. /* Read one char from open configfile_t, increase line number upon LF */
  1003. API_EXPORT(int) ap_cfg_getc(configfile_t *cfp);
  1004.  
  1005. /* Detach from open configfile_t, calling the close handler */
  1006. API_EXPORT(int) ap_cfg_closefile(configfile_t *cfp);
  1007.  
  1008. #ifdef NEED_STRERROR
  1009. char *strerror(int err);
  1010. #endif
  1011.  
  1012. /* Misc system hackery */
  1013.  
  1014. API_EXPORT(uid_t) ap_uname2id(const char *name);
  1015. API_EXPORT(gid_t) ap_gname2id(const char *name);
  1016. API_EXPORT(int) ap_is_directory(const char *name);
  1017. API_EXPORT(int) ap_can_exec(const struct stat *);
  1018. API_EXPORT(void) ap_chdir_file(const char *file);
  1019.  
  1020. #ifndef HAVE_CANONICAL_FILENAME
  1021. /*
  1022.  *  We can't define these in os.h because of dependence on pool pointer.
  1023.  */
  1024. #define ap_os_canonical_filename(p,f)  (f)
  1025. #define ap_os_case_canonical_filename(p,f)  (f)
  1026. #define ap_os_systemcase_filename(p,f)  (f)
  1027. #else
  1028. API_EXPORT(char *) ap_os_canonical_filename(pool *p, const char *file);
  1029. #ifdef WIN32
  1030. API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile);
  1031. API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile);
  1032. #else
  1033. #define ap_os_case_canonical_filename(p,f) ap_os_canonical_filename(p,f)
  1034. #define ap_os_systemcase_filename(p,f) ap_os_canonical_filename(p,f)
  1035. #endif
  1036. #endif
  1037.  
  1038. #ifdef _OSD_POSIX
  1039. extern const char *os_set_account(pool *p, const char *account);
  1040. extern int os_init_job_environment(server_rec *s, const char *user_name, int one_process);
  1041. #endif /* _OSD_POSIX */
  1042.  
  1043. char *ap_get_local_host(pool *);
  1044. unsigned long ap_get_virthost_addr(char *hostname, unsigned short *port);
  1045.  
  1046. extern API_VAR_EXPORT time_t ap_restart_time;
  1047.  
  1048. /*
  1049.  * Apache tries to keep all of its long term filehandles (such as log files,
  1050.  * and sockets) above this number.  This is to workaround problems in many
  1051.  * third party libraries that are compiled with a small FD_SETSIZE.  There
  1052.  * should be no reason to lower this, because it's only advisory.  If a file
  1053.  * can't be allocated above this number then it will remain in the "slack"
  1054.  * area.
  1055.  *
  1056.  * Only the low slack line is used by default.  If HIGH_SLACK_LINE is defined
  1057.  * then an attempt is also made to keep all non-FILE * files above the high
  1058.  * slack line.  This is to work around a Solaris C library limitation, where it
  1059.  * uses an unsigned char to store the file descriptor.
  1060.  */
  1061. #ifndef LOW_SLACK_LINE
  1062. #define LOW_SLACK_LINE    15
  1063. #endif
  1064. /* #define HIGH_SLACK_LINE      255 */
  1065.  
  1066. /*
  1067.  * The ap_slack() function takes a fd, and tries to move it above the indicated
  1068.  * line.  It returns an fd which may or may not have moved above the line, and
  1069.  * never fails.  If the high line was requested and it fails it will also try
  1070.  * the low line.
  1071.  */
  1072. #ifdef NO_SLACK
  1073. #define ap_slack(fd,line)   (fd)
  1074. #else
  1075. int ap_slack(int fd, int line);
  1076. #define AP_SLACK_LOW    1
  1077. #define AP_SLACK_HIGH    2
  1078. #endif
  1079.  
  1080. API_EXPORT(char *) ap_escape_quotes(pool *p, const char *instr);
  1081.  
  1082. /*
  1083.  * Redefine assert() to something more useful for an Apache...
  1084.  */
  1085. API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine)
  1086.                 __attribute__((noreturn));
  1087. #define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__))
  1088.  
  1089. /* The optimized timeout code only works if we're not MULTITHREAD and we're
  1090.  * also not using a scoreboard file
  1091.  */
  1092. #if !defined (MULTITHREAD) && \
  1093.     (defined (USE_MMAP_SCOREBOARD) || defined (USE_SHMGET_SCOREBOARD))
  1094. #define OPTIMIZE_TIMEOUTS
  1095. #endif
  1096.  
  1097. /* A set of flags which indicate places where the server should raise(SIGSTOP).
  1098.  * This is useful for debugging, because you can then attach to that process
  1099.  * with gdb and continue.  This is important in cases where one_process
  1100.  * debugging isn't possible.
  1101.  */
  1102. #define SIGSTOP_DETACH            1
  1103. #define SIGSTOP_MAKE_CHILD        2
  1104. #define SIGSTOP_SPAWN_CHILD        4
  1105. #define SIGSTOP_PIPED_LOG_SPAWN        8
  1106. #define SIGSTOP_CGI_CHILD        16
  1107.  
  1108. #ifdef DEBUG_SIGSTOP
  1109. extern int raise_sigstop_flags;
  1110. #define RAISE_SIGSTOP(x)    do { \
  1111.     if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\
  1112.     } while (0)
  1113. #else
  1114. #define RAISE_SIGSTOP(x)
  1115. #endif
  1116.  
  1117. API_EXPORT(extern const char *) ap_psignature(const char *prefix, request_rec *r);
  1118.  
  1119. /* strtoul does not exist on sunos4. */
  1120. #ifdef strtoul
  1121. #undef strtoul
  1122. #endif
  1123. #define strtoul strtoul_is_not_a_portable_function_use_strtol_instead
  1124.  
  1125. #ifdef __cplusplus
  1126. }
  1127. #endif
  1128.  
  1129. #endif    /* !APACHE_HTTPD_H */
  1130.